package util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class CodeUtil {

    public static String getCode() {

        char[] chs = new char[52];
        char[] number = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
        for (int i = 0; i < chs.length; i++)
            if (i <= 25) {
                chs[i] = (char) (97 + i);
            } else {
                chs[i] = (char) (65 + i - 26);
            }
        Random r = new Random();
        ArrayList<Character> result = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            result.add(chs[r.nextInt(52)]);
        }
        result.add(number[r.nextInt(10)]);
        Collections.shuffle(result);
        String ret = "";
        for (Character c : result) {
            ret += c;
        }
        return ret;
    }

}